import React, { useState } from 'react';

function Counter() {
  const [count, setCount] = useState(10);

  // 减法按钮的点击处理函数
  const handleDecrement = () => {
    setCount(prevCount => prevCount > 1 ? prevCount - 1 : prevCount);
  };

  return (
    <div>
      <button 
        onClick={handleDecrement}
        disabled={count === 1} // 当count为1时禁用按钮
      >
        减少
      </button>
      <span>{count}</span>
      <button onClick={() => setCount(count + 1)}>
        增加
      </button>
    </div>
  );
}

export default Counter; 